<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.hnluchuan.staff.dto.*" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>

<%@include file="/common/head.jsp" %>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <form action="${ctx }/admin/employee/save?id=${n.id }" id="detail-form" class="form-horizontal" method="post">
        <div align="center" style="font-size: 23px">员工基本信息</div>
        <div class="form-group">
            <!-- 用户ID -->
            <%--<label class="col-sm-2 control-label">用户ID</label>--%>
            <%--<div class="col-sm-4">--%>
            <input type="hidden" id="user-id" name="user.id" value="${n.user.id }" class="form-control">
            <input type="hidden"  placeholder="请选择用户ID" class="form-control" id="user-name" value="${n.user.id }"
            onclick="bring({
            url:'${ctx}/admin/user/search',
            name: 'id',
            idInput: 'user-id',
            nameInput: 'user-name'
            })" />

            <%--</div>--%>

            <!-- 岗位 -->
            <label class="col-sm-2 control-label">岗位</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="position" value="${n.position }">
            </div>

        <c:if test="${type==1}">
            <label class="col-sm-2 control-label">部门</label>
            <div class="col-sm-4">

            <select name="department.id" class="form-control">
                <option value="${n.department.id}">当前部门:${n.department.name }</option>
                <c:forEach items="${delist}" var="n" varStatus="idx">
                    <option value="${n.id}">${n.name}</option>
                </c:forEach>
            </select>
            </div>
        </c:if>
            <c:if test="${type!=1}">
                <label class="col-sm-2 control-label">部门</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="n..departmentDTO.name" value="${n.department.name }">
                </div>
            </c:if>
        </div>
        <div class="form-group">

            <!-- 姓名 -->
            <label class="col-sm-2 control-label">姓名</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="name" value="${n.name }">
            </div>

            <!-- 出生日期 -->
            <label class="col-sm-2 control-label">出生日期</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="birth" value="<fmt:formatDate value='${n.birth }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: ''})">
            </div>
        </div>
        <div class="form-group">

            <!-- 性别 -->
            <label class="col-sm-2 control-label">性别</label>
            <div class="col-sm-4">
                <c:if test="${n.sex==1}">
                    男<input type="radio" name="sex" value="1" checked="checked">
                    女<input type="radio" name="sex" value="0">
                </c:if>
                <c:if test="${n.sex==0}">
                    男<input type="radio" name="sex" value="1" >
                    女<input type="radio" name="sex" value="0" checked="checked">
                </c:if>
                <c:if test="${n.sex==null}">
                    男<input type="radio" name="sex" value="1" >
                    女<input type="radio" name="sex" value="0">
                </c:if>
                <%--<input type="text" class="form-control" name="sex" value="${n.sex }">--%>
            </div>

            <!-- 身高 -->
            <label class="col-sm-2 control-label">身高</label>
            <div class="col-sm-4">
                <c:if test="${type==1}">
                    <input type="text" class="form-control" name="height" value="${n.height }">
                </c:if>
                <c:if test="${type!=1}">
                    <input type="text" class="form-control" name="height" value="${n.height }厘米">
                </c:if>

            </div>
        </div>
        <div class="form-group">

            <!-- 体重 -->
            <label class="col-sm-2 control-label">体重</label>
            <div class="col-sm-4">
                <c:if test="${type==1}">
                    <input type="text" class="form-control"  name="weight" value="${n.weight }">
                </c:if>
                <c:if test="${type!=1}">
                    <input type="text" class="form-control"  name="weight" value="${n.weight }千克">
                </c:if>
            </div>

            <!-- 籍贯 -->
            <label class="col-sm-2 control-label">籍贯</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="place" value="${n.place }">
            </div>
        </div>
        <div class="form-group">

            <!-- 民族 -->
            <label class="col-sm-2 control-label">民族</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="nation" value="${n.nation }">
            </div>

            <!-- 联系电话 -->
            <label class="col-sm-2 control-label">联系电话</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="phone" value="${n.phone }">
            </div>
        </div>
        <div class="form-group">

            <!-- 身份证号 -->
            <label class="col-sm-2 control-label">身份证号</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="iDCard" value="${n.IDCard }">
            </div>

            <!-- 毕业学校 -->
            <label class="col-sm-2 control-label">毕业学校</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="school" value="${n.school }">
            </div>
        </div>
        <div class="form-group">

            <!-- 专业 -->
            <label class="col-sm-2 control-label">专业</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="major" value="${n.major }">
            </div>

            <!-- 学历 -->
            <label class="col-sm-2 control-label">学历</label>
            <div class="col-sm-4">
                <%--<input type="text" class="form-control" name="education" value="${n.education }">--%>
                <c:if test="${n.education==1}">
                    <select name="education" class="form-control">
                        <option value="1" selected>大专</option>
                        <option value="2">本科</option>
                        <option value="3">研究生</option>
                    </select>
                </c:if>
                <c:if test="${n.education==2}" >
                    <select name="education" class="form-control">
                        <option value="1">大专</option>
                        <option value="2" selected>本科</option>
                        <option value="3">研究生</option>
                    </select>
                </c:if>
                <c:if test="${n.education==3}" >
                    <select name="education" class="form-control">
                        <option value="1">大专</option>
                        <option value="2">本科</option>
                        <option value="3" selected>研究生</option>
                    </select>
                </c:if>
            </div>
        </div>
        <div class="form-group">

            <!-- 户口所在地 -->
            <label class="col-sm-2 control-label">户口所在地</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="location" value="${n.location }">
            </div>

            <!-- 居住地址 -->
            <label class="col-sm-2 control-label">居住地址</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="address" value="${n.address }">
            </div>
        </div>
        <div class="form-group">

            <!-- 微信号 -->
            <label class="col-sm-2 control-label">微信号</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="wechat" value="${n.wechat }">
            </div>

            <!-- 邮箱 -->
            <label class="col-sm-2 control-label">邮箱</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="email" value="${n.email }">
            </div>
        </div>
        <div class="form-group">

            <!-- 婚姻状况 -->
            <label class="col-sm-2 control-label">婚姻状况</label>
            <div class="col-sm-4">
                <%--<input type="text" class="form-control" name="marry" value="${n.marry }">--%>
                <c:if test="${n.marry==1}">
                    <select name="marry" class="form-control">
                        <option value="1" selected>已婚</option>
                        <option value="2">未婚</option>
                    </select>
                </c:if>
                <c:if test="${n.marry==2}" >
                    <select name="marry" class="form-control">
                        <option value="1">已婚</option>
                        <option value="2" selected>未婚</option>
                    </select>

                </c:if>
            </div>

            <!-- 入职时间 -->
            <label class="col-sm-2 control-label">入职时间</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="inTime" value="<fmt:formatDate value='${n.inTime }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: ''})">
            </div>
        </div>
        <%
            Integer type=(Integer) request.getAttribute("type");
            if(type==1)
            {
        %>
        <div class="form-group">

            <!-- 员工状态/1.录用/2.停职 -->
            <label class="col-sm-2 control-label">员工状态</label>

            <div class="col-sm-4">
                ${enum:detail('EmployeeStatus', 'status', n.status)}
            </div>

        </div>
        <%

        }else
        {
        %>

        <div class="form-group">

      <c:if test="${type==1}">
          <!-- 员工状态/1.录用/2.停职 -->
          <label class="col-sm-2 control-label">员工状态</label>
          <label class="col-sm-2 control-label">员工状态/1.录用/2.离职/3.转正</label>
          <div class="col-sm-4">

              <input type="text" class="form-control"  value="${n.status}" />
          </div>

      </c:if>

        </div>
        <%
        }%>



        <%
            List<ExperienceDTO> exlist=(ArrayList<ExperienceDTO>)request.getAttribute("exlist");
            List<EmergencyContactDTO> emlist=(ArrayList<EmergencyContactDTO>)request.getAttribute("emlist");
            List<FamilyDTO> falist=(ArrayList<FamilyDTO>)request.getAttribute("falist");
            List<EducationDTO> edlist=(ArrayList<EducationDTO>)request.getAttribute("edlist");
            List<EmployeeFileDTO> filist=(ArrayList<EmployeeFileDTO>)request.getAttribute("filist");
        %>

        <!-- 员工状态/1.录用/2.停职 -->

            <%
                if(edlist!=null)
                {
            %>
        <div class="form-group">
                     <%
                         int a=0;
                    for (EducationDTO e:edlist
                            ) {
            %>
            <ul align="center" >
                <li style="font-size:23px;list-style-type:none" >学历</li>
                <label class="col-sm-2 control-label">起始时间</label>
                <input type="hidden" id="educationsDTOS-id" name="educationsDTOS[<%=a%>].id" value='<%=e.getId()%> 'class="form-control">
                <input type="hidden" id="educationsDTOS-eid" name="educationsDTOS[<%=a%>].employee.id" value='<%=e.getEmployee().getId()%>' class="form-control">
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="educationsDTOS[<%=a%>].start" value="<fmt:formatDate value='<%=e.getStart()%>' pattern='yyyy-MM-dd'/>"  onclick="laydate({format: ''})"/>
                </div>

                <!-- 出生日期 -->
                <label class="col-sm-2 control-label">结束时间</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control"  name="educationsDTOS[<%=a%>].end" value="<fmt:formatDate value='<%=e.getStart()%>' pattern='yyyy-MM-dd'/>"   onclick="laydate({format: ''})"/>
                </div>
                <label class="col-sm-2 control-label">专业</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="educationsDTOS[<%=a%>].major" value="<%=e.getMajor()%>"/>
                </div>

                <!-- 出生日期 -->
                <label class="col-sm-2 control-label">学历</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="educationsDTOS[<%=a%>].record" value="<%=e.getRecord()%>"  />
                </div>
                <label class="col-sm-2 control-label">证书</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="educationsDTOS[<%=a%>].certificate" value="<%=e.getCertificate()%>" />
                </div>


            </ul>
            <%
                  a++;  }
              %>
        </div>
<%
                }
            %>


            <%
                if(exlist!=null){
            %>
             <div class="form-group">
            <%
                  int b=0;
                    for (ExperienceDTO e:exlist
                            ) {
            %>
                 <ul align="center" >
                <li style="font-size:23px;list-style-type:none" >工作经验</li>

                <input type="hidden" id="-id" name="experienceDTOS[<%=b%>].id" value="<%=e.getId()%>" class="form-control">
                <input type="hidden"  class="form-control" id="-name" name="experienceDTOS[<%=b%>].employee.id" value="<%=e.getEmployee().getId()%>">
                <label class="col-sm-2 control-label">离职原因</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="experienceDTOS[<%=b%>].reason" value="<%=e.getReason()%>"  />
                </div>
                <!-- 出生日期 -->
                <label class="col-sm-2 control-label">单位</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="experienceDTOS[<%=b%>].company" value="<%=e.getCompany()%>"  />
                </div>
                <label class="col-sm-2 control-label">工作</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="experienceDTOS[<%=b%>].work" value="<%=e.getWork()%>" />
                </div>
                <!-- 出生日期 -->
                <label class="col-sm-2 control-label">职位</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control"  name="experienceDTOS[<%=b%>].position" value="<%=e.getPosition()%>" />
                </div>
                <label class="col-sm-2 control-label">起始时间</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="experienceDTOS[<%=b%>].start" value="<fmt:formatDate value='<%=e.getStart()%>' pattern='yyyy-MM-dd'/>"  onclick="laydate({format: ''})"/>
                </div>

                <!-- 出生日期 -->
                <label class="col-sm-2 control-label">结束时间</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control"  name="experienceDTOS[<%=b%>].end" value="<fmt:formatDate value='<%=e.getEnd()%>' pattern='yyyy-MM-dd'/>"  onclick="laydate({format: ''})"/>
                </div>
            </ul>
            <%
               b++; }
            %>
        </div>
        <%
            }
        %>


            <%
                if(falist!=null){
            %>
        <div class="form-group">
            <%
                int c=0;
                    for (FamilyDTO e:falist
                            ) {
            %>
            <ul align="center" >
                <li style="font-size:23px;list-style-type:none" >家庭成员</li>

                <input type="hidden" id="employee-id" name="familyDTOS[<%=c%>].id" value="<%=e.getId()%>" class="form-control">
                <input  type="hidden"  placeholder="请选择员工ID" name="familyDTOS[<%=c%>].employee.id" class="form-control" id="employee-name" value="<%=e.getEmployee().getId()%>">
                <label class="col-sm-2 control-label">姓名</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="familyDTOS[<%=c%>].name" value="<%=e.getName()%>">
                </div>

                <!-- 出生日期 -->
                <label class="col-sm-2 control-label">关系</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="familyDTOS[<%=c%>].relation" value="<%=e.getRelation()%>" >
                </div>
                <label class="col-sm-2 control-label">联系方式</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="familyDTOS[<%=c%>].contact"  value="<%=e.getContact()%>">
                </div>

                <!-- 出生日期 -->
                <label class="col-sm-2 control-label">年龄</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="familyDTOS[<%=c%>].age" value="<%=e.getAge()%>" >
                </div>
                <label class="col-sm-2 control-label">工作单位</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="familyDTOS[<%=c%>].company" value=" <%=e.getCompany()%>" >
                </div>

                <!-- 出生日期 -->
                <label class="col-sm-2 control-label">职位</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="familyDTOS[<%=c%>].position" value="<%=e.getPosition()%>" >
                </div>
                <%--<li>姓名 <input type="text" class="form-control"  value="<%=e.getName()%>"  style="width:300px;//宽度 height=20px;//高度"/></li>--%>
            </ul>
            <%
              c++;  }
            %>
        </div>
        <%
            }
        %>

            <%
                if(emlist!=null){

                %>
        <div class="form-group">
            <%
                int d=0;
                    for (EmergencyContactDTO e:emlist
                            ) {
            %>
            <ul align="center" >
                <li style="font-size:23px;list-style-type:none" >紧急联系人</li>

                <label class="col-sm-2 control-label">姓名</label>
                <input type="hidden" name="emergencyContactDTOS[<%=d%>].id" value="<%=e.getId()%>" class="form-control">
                <input type="hidden"  placeholder="请选择员工ID" name="emergencyContactDTOS[<%=d%>].employee.id" class="form-control" value="<%=e.getEmployee().getId()%>">
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="emergencyContactDTOS[<%=d%>].name" value="<%=e.getName()%>"/>
                </div>

                <!-- 出生日期 -->
                <label class="col-sm-2 control-label">关系</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="emergencyContactDTOS[<%=d%>].relation" value="<%=e.getRelation()%>"/>
                </div>
                <label class="col-sm-2 control-label">电话</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="emergencyContactDTOS[<%=d%>].phone" value="<%=e.getPhone()%>"/>
                </div>

                <!-- 出生日期 -->
                <label class="col-sm-2 control-label">单位或地址</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="emergencyContactDTOS[<%=d%>].address" value="<%=e.getAddress()%>"  />
                </div>
            </ul>
            <%
              d++ ; }
            %>
        </div>
        <%
            }
        %>


        <%
            if(filist!=null){

        %>
        <div class="form-group" align="center">
                <%

                    for (EmployeeFileDTO e:filist
                            ) {
            %>
            描述:<%=e.getFiledescribe()%> 文件名:<%=e.getFilename()%>
                    <a href="${ctx }/admin/employee/download?filename=<%=e.getFilename()%>&id=${n.user.id}">
                       下载
                    </a><br>
        <%
                     }}
                        %>
    </form>
</div>


<%@include file="/common/foot.jsp" %>

</body>
</html>
